package com.runmyai.aitools.model;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wry
 */
@Data
@NoArgsConstructor
public class AiRequest {

    /**
     * 发起请求时必须是奇数个元素
     */
    private List<Chat> messages;

    /**
     * 预设, 预设信息, 不超过1024个字符
      */
    private String system;

    private String temperature;

    private String topP;

    public AiRequest(String content) {
        this.query(content);
    }

    public void query(String content) {
        Assert.state(StringUtils.hasText(content), "提示词不能为空! 请检查提示词模板和提问内容");
        Chat chat = Chat.user(content);
        if (this.messages == null) {
            this.messages = new ArrayList<>();
        }
        this.messages.add(chat);
    }

}
